<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
    <head>
        <th:block th:include="include :: header('修改流程类别明细')"/>
    </head>
    <body class="white-bg">
        <div class="wrapper wrapper-content animated fadeInRight ibox-content">
            <form class="form-horizontal m" id="form-info-edit" th:object="${flowCategoryInfo}">
                <input name="id" th:field="*{id}" type="hidden">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">类别明细名称：</label>
                    <div class="col-sm-8">
                        <input name="name" th:field="*{name}" class="form-control" type="text" autocomplete="off" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">流程类型：</label>
                    <div class="col-sm-8">
                        <select name="flowCategory.id" id="flowCategoryName" class="form-control" required>
                            <option value="">-请选择-</option>
                            <option th:each="flowCategory : ${flowCategoryList}" th:selected="${flowCategoryInfo.flowCategory.id eq flowCategory.id}" th:text="${flowCategory.name}" th:value="${flowCategory.id}"></option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">是否是假期：</label>
                    <div class="col-sm-8">
                        <div class="radio-box" th:each="dict : ${@dict.getType('sys_yes_no')}">
                            <input type="radio" th:id="${'isHoliday_' + dict.dictCode}" name="isHoliday" th:value="${dict.dictValue}" th:field="*{isHoliday}" autocomplete="off" required>
                            <label th:for="${'isHoliday_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                            <div class="black">
                                <label th:if="${dict.dictValue == 'Y'}">请假时段中包含员工的休息日,会计入请假天数</label>
                                <label th:if="${dict.dictValue == 'N'}">请假时段中不包含员工的休息日,不会计入请假天数</label>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <th:block th:include="include :: footer"/>
        <script th:inline="javascript">
            var prefix = ctx + "oa/info";
            $("#form-info-edit").validate({
                focusCleanup: true
            });

            $(function () {
                /*渲染下拉框*/
                $.ajax({
                    url: "/oa/category/list",
                    type: 'POST',
                    dataType: 'json',
                    success: function (data) {
                        var select = $("#flowCategoryName");
                        var dictId = [[${flowCategoryInfo.flowCategory.id}]];
                        for (let i = 0; i < data.rows.length; i++) {
                            if (dictId == data.rows[i].id) {
                                select.append("<option value='" + data.rows[i].id + "' selected>" + data.rows[i].name + "</option>");
                                continue;
                            }
                            select.append("<option value='" + data.rows[i].id + "'>" + data.rows[i].name + "</option>");
                        }
                    }
                })
            })

            function submitHandler() {
                if ($.validate.form()) {
                    $.operate.save(prefix + "/edit", $('#form-info-edit').serialize());
                }
            }
        </script>
    </body>
</html>